package com.saver.view.dialog;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.saver.R;
import com.saver.core.domain.Banco;

public class BancoSpinnerAdapter extends ArrayAdapter<Banco> {

	public BancoSpinnerAdapter(Context context, 
							  int textViewResourceId,
							  Banco[] objects) {
		super(context, textViewResourceId, objects);
	}
	
	@Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return getCustomView(position, convertView, parent);
	}
	
	public View getCustomView(int position, View convertView, ViewGroup parent) {
	        View view = convertView == null ? LayoutInflater.from(
	        							getContext()).inflate(R.layout.item_banco, parent, false) : convertView;
	        TextView nombreBanco = (TextView) view.findViewById(R.id.nombre_banco_list);
	        Banco banco = getItem(position);
	        nombreBanco.setText(banco.getNombre().trim().toUpperCase());
	        int color = Color.rgb(214, 214, 214);
	        int colorText = Color.rgb(0, 0, 0);
	        view.setBackgroundColor(color & 0x60FFFFFF);
	        nombreBanco.setTextColor(colorText);
	        return view;
	}
}
